package com.ys.erp.entity.data.bean;

import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.annotation.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

/**
 * @author minamiyama
 * @date 2025/5/19 11:06
 *  首页聚合区实体类
 */

@Data
@TableName("t_mall_home_group_area")
public class MallHomeGroupArea {
    @TableId(type = IdType.AUTO)
    private Long id;

    @TableField("type")
    private String type;

    @TableField("no")
    private String no;

    @TableField(value = "title")
    private String title;

    @TableField(value = "back_ground_image",updateStrategy = FieldStrategy.IGNORED)
    private String backgroundImage;

    @TableField(value = "title_tag", updateStrategy = FieldStrategy.IGNORED)
    private String titleTag;

    @TableField("sub_title_type")
    private String subTitleType;

    @TableField(value = "sub_title", updateStrategy = FieldStrategy.IGNORED)
    private String subTitle;

    @TableField(value = "sub_title_color" , updateStrategy = FieldStrategy.IGNORED)
    private String subTitleColor;

    @TableField("location")
    private Integer location;

    @TableField("is_cate")
    private Integer isCate;

    @TableField("goods_setting_type")
    private String goodsSettingType;

    @TableField("import_rule_json")
    private String importRuleJson;

    @TableField("status")
    private Integer status;

    @TableField("emp_name")
    private String empName;

    @TableField("emp_phone")
    private String empPhone;

    @TableField("emp_id")
    private Long empId;

    @TableField("version")
    @Version
    private Integer version;

    @TableField(value = "create_time")
    private LocalDateTime createTime;

    @TableField(value = "update_time", update = "now()")
    private LocalDateTime updateTime;

    @Data
    public static class ImportRuleDTO {

        private String type;

        private Integer day;

        private Integer num;
    }


    public ImportRuleDTO getImportRule() {
        return JSONObject.parseObject(this.getImportRuleJson(), ImportRuleDTO.class);
    }

    @AllArgsConstructor
    @Getter
    public enum Enums {

        MANUAL, ONLY_GOODS, IMPORT_RULE, NEW_LINE,QUALITY,NEW,RANKING;

    }

    public static final Map<String, String> ENUM_MAP = new HashMap<>();

    static {
        ENUM_MAP.put(Enums.MANUAL.toString(), "手动配置");
        ENUM_MAP.put(Enums.ONLY_GOODS.toString(), "指定唯一商品");
        ENUM_MAP.put(Enums.IMPORT_RULE.toString(), "规则引用");
        ENUM_MAP.put(Enums.NEW_LINE.toString(), "上新引用");
        ENUM_MAP.put(Enums.QUALITY.toString(), "品质推荐");
        ENUM_MAP.put(Enums.NEW.toString(), "新品推荐");
        ENUM_MAP.put(Enums.RANKING.toString(), "榜单推荐");
    }
}
